package com.alageek.crowd.mvc.config;

import com.alageek.crowd.entity.Admin;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.List;

/**
 * User中只包含账号密码，扩展User类以获取原始的Admin对象
 * @author alageek
 */
public class SecurityAdmin extends User {

    private static final long serialVersionUID = -8657861740764228530L;

    private Admin originalAdmin;

    public SecurityAdmin(Admin originalAdmin, List<GrantedAuthority> authorityList){
        super(originalAdmin.getLoginAcct(), originalAdmin.getUserPswd(), authorityList);
        this.originalAdmin = originalAdmin;
        this.originalAdmin.setUserPswd(null);
    }

    public Admin getOriginalAdmin(){
        return originalAdmin;
    }

}
